package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.project.entity.FinanceProductInterestItemEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;
import com.yuexunit.persist.annotation.Transactional;

/**
*@version 创建时间：2016年10月31日 上午10:12:42
*@author NTBK-021-1006
*类说明
*/

@Implements(FinanceProductInterestItemService.class)
public class FinanceProductInterestItemServiceImpl implements FinanceProductInterestItemService {

	@Override
	@Transactional
	public Long createFinanceProductInterestItem(FinanceProductInterestItemEntity entity) {
		PersistUtil.insertOrUpdate(entity);
		return entity.getFinanceProductInterestItemId();
	}

	@Override
	@Transactional
	public void updateFinanceProductInterestItem(FinanceProductInterestItemEntity entity) {
		PersistUtil.update(entity);
	}

	@Override
	@Transactional
	public void deleteFinanceProductInterestItem(Long financeProductInterestItemId) {
		PersistUtil.delete(FinanceProductInterestItemEntity.class, financeProductInterestItemId);
	}

	@Override
	public List<FinanceProductInterestItemEntity> inquireFinanceProductInterestItemList(Long financeProductId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(FinanceProductInterestItemEntity.class);
		criteria.add(Restrictions.eq("financeProductId", financeProductId));
		return PersistUtil.get(criteria);
	}

	@Override
	public FinanceProductInterestItemEntity inquireFinanceProductInterestItem(Long financeProductInterestItemId) {
		return PersistUtil.get(FinanceProductInterestItemEntity.class, financeProductInterestItemId);
	}
}
